﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DynORM.Enums;
using DynORM.Interfaces.BLLMapper;

namespace DynORM.Interfaces
{
    public class BLLSuperType
    {
        LoadStatus Status = LoadStatus.Ghost;

        public Boolean IsGhost
        {
            get { return this.Status == LoadStatus.Ghost; }
        }
        public Boolean IsLoaded
        {
            get { return this.Status == LoadStatus.Loaded; }
        }
        public Boolean IsLoading
        {
            get { return this.Status == LoadStatus.Loading; }
        }
        public void MarkAsGhost()
        {
            //if (!(IsLoading) && !(IsLoaded))
                this.Status = LoadStatus.Ghost;
        }
        public void MarkAsLoading()
        {
            if (this.IsGhost)
                this.Status = LoadStatus.Loading;
        }
        public void MarkAsLoaded()
        {
            if (this.IsLoading || this.IsGhost)
                this.Status = LoadStatus.Loaded;
        }
        protected void Load(IBLLAdaptiveMapper mapper) 
        {
            if (this.IsGhost)
            {
                mapper.UploadLazy(this);
            }
        }
    }
}
